//
//  LeadViewController.m
//  CapriceMusic
//
//  Created by dllo on 16/1/18.
//  Copyright © 2016年 MYX. All rights reserved.
//

#import "LeadViewController.h"

@interface LeadViewController ()
@property (nonatomic, strong) UIImageView *imageView;

@end

@implementation LeadViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createLead];
    // Do any additional setup after loading the view.
}

- (void)createLead {
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    [scrollView setContentSize:CGSizeMake(self.view.width * 3, 0)];
    scrollView.pagingEnabled = YES;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.bounces = NO;
    for (int i = 0; i < 3; i++) {
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * self.view.width, 0, self.view.width, self.view.height)];
        NSString *imageName = [NSString stringWithFormat:@"%d.jpg", i];
        self.imageView.image = [UIImage imageNamed:imageName];
        [scrollView addSubview:self.imageView];
        if (i == 2) {
            UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button.frame = CGRectMake(self.view.frame.size.width / 2 - 50 , self.view.frame.size.height - 100, 100, 50);
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            button.layer.cornerRadius = 10;
            button.backgroundColor = [UIColor clearColor];
            [button setTitle:@"立即体验" forState:UIControlStateNormal];
            [button addTarget:self action:@selector(ButtonDidPress:) forControlEvents:UIControlEventTouchUpInside];
            [self.imageView addSubview:button];
        }
        self.imageView.userInteractionEnabled = YES;
    }
    [self.view addSubview:scrollView];
}

- (void)ButtonDidPress:(UIButton *)sender {
    [self.delegate chooseVC];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
